package com.zoewin.zephyr.reportjasper.factory;

import com.zoewin.zephyr.reportjasper.entity.FileType;
import com.zoewin.zephyr.reportjasper.factory.exporter.*;

/**
 * Created by WQL on 2019/12/18
 * CEASE TO STRUGGLE AND YOU CEASE TO LIVE
 * 采用简单工厂的方式，根据文件类型创建对应的对象
 */
public class ExportFactory {
    private static IExporter exporter;

    //声明为最终方法防止被覆盖
    public final static IExporter getExport(FileType fileType) {
        switch (fileType) {
            case HTML: {
                setExporter(new HtmlExpoter());
                break;
            }
            case PDF:{
                setExporter(new PdfExporter());
                break;
            }
            case XLS:{
                setExporter(new XlsExporter());
                break;
            }
            case WORD:{
                setExporter(new WordExporter());
                break;
            }
            case poiWORD:{
                setExporter(new POIWordExporter());
            }
        }
        return exporter;
    }

    private static void setExporter (IExporter iExporter){
        exporter=iExporter;
    }
}
